package it.desertsupport.spring.service;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class MyServiceFactory {
	
	private static ApplicationContext ctx;

	static {
		try {

			ctx = new ClassPathXmlApplicationContext("\\it\\desertsupport\\spring\\applicationContext.xml");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	
	public static UserService getUserService(){
		
		return (UserService) ctx.getBean("userservice");
	}
	
	
	
	
	public static RoleService getRoleService(){
		
		return (RoleService) ctx.getBean("roleservice");
	}
	
	

	public static ProfileService getProfileService(){
		
		return (ProfileService) ctx.getBean("profileservice");
	}
	
	
	
	public static ArmyService getArmyService(){
		
		return (ArmyService) ctx.getBean("armyservice");
	}
	
	
	public static DefenceService getDefenceService(){
		
		return (DefenceService) ctx.getBean("defenceservice"); 
	}
}
